<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" @submit.native.prevent>
      <el-form-item label="接口代码" prop="interfaceCode">
        <el-input v-model="queryParams.interfaceCode" placeholder="接口代码、接口描述" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="状态" prop="isOk">
        <el-select v-model="queryParams.isOk" placeholder="状态选择" clearable style="width: 240px">
          <el-option v-for="dict in this.messageStatusList" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['luckDraw:prize:query']">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table :height="tableHeight" v-loading="loading" :data="list" stripe border>
      <el-table-column label="序号" type="index" width="60" align="center" />
      <el-table-column label="创建时间" prop="createTime" width="160" />
      <el-table-column label="接口代码" prop="interfaceCode" width="" />
      <el-table-column label="接口描述" prop="interfaceDescribe" width="200" />
      <el-table-column label="银行请求代码" width="150" prop="sendBody" align="center" />
      <el-table-column label="银行接口返回源码" prop="strBody" align="center" class-name="fixed-width" :show-overflow-tooltip="true" />
      <el-table-column label="请求状态" prop="isOk" align="center">
        <template slot-scope="scope">
          {{scope.row.isOk?'失败':'成功'}}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="120">
        <template slot-scope="scope" v-if="scope.row.roleId !== 1">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['luckDraw:prize:edit']">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <Z-Dialog :title="title" :visible.sync="open" :isShowConfirm="false">
      <el-form ref="form" :model="form" label-width="140px">

        <el-form-item label="银行接口返回源码" prop="strBody">
          <el-input v-model="form.strBody" :readonly="true" type="textarea" />
        </el-form-item>
        <el-form-item label="银行请求源码" prop="sendBody">
          <el-input v-model="form.sendBody" :readonly="true" />
        </el-form-item>
        <el-form-item label="接口代码" prop="interfaceCode">
          <el-input v-model="form.interfaceCode" :readonly="true" />
        </el-form-item>
        <el-form-item label="接口描述" prop="interfaceDescribe">
          <el-input v-model="form.interfaceDescribe" :readonly="true" />
        </el-form-item>
        <el-form-item label="请求状态" prop="isOk">
          <el-input :rows="2" :readonly="true" v-model="form.isOk">
          </el-input>
        </el-form-item>

      </el-form>
    </Z-Dialog>
  </div>
</template>

<script>
import tableImage from "@/components/TableImageView/index.vue";
import { listBankrecordlog } from "@/api/operation/bankrecordlog";

export default {
  components: { tableImage },
  name: "reconciliation",  //对账日志
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: this.global.pageSize,
        interfaceCode: undefined,
      },
      // 表单参数
      form: {},

      messageStatus: [
        { label: "成功", value: 0 },
        { label: "失败", value: 1 },
        { label: "待核查", value: 2 }
      ]
    };
  },

  computed: {
    tableHeight() {
      return 'calc(100vh - 280px)'
    },
    messageStatusList() {
      let typeDictArray = JSON.parse(
        JSON.stringify(this.messageStatus)
      );
      typeDictArray.unshift({ label: "全部", value: undefined });
      return typeDictArray;
    },
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      listBankrecordlog(this.queryParams)
        .then((response) => {
          if (response.code == 200) {
            this.list = response.data;
            this.total = response.total;
          }
          this.loading = false;
        })
        .catch((err) => {
          this.loading = false;
        });
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    // 表单重置
    reset() {
      this.form = {}
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },


    /** 查看按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.open = true;
      this.title = "日志详情";
      this.form = row;
    },
  },
};
</script>
<style scoped>
.el-tooltip__popper {
  max-width: 50%;
}
.input-W {
  width: 240px;
}
</style>
